#ifndef GTKTESTER_VALIDATIONS_H
#define GTKTESTER_VALIDATIONS_H

#define gtktester_abort_if_null(widget, name) if (!widget) { PyErr_Format(PyExc_ValueError, "No such widget '%s'", name); return NULL; }
#define gtktester_abort_if_not_button(widget, name) if (!GTK_IS_BUTTON(widget)) { PyErr_Format(PyExc_ValueError, "Widget '%s' is not a button", name); return NULL; }
#define gtktester_abort_if_not_toggle_button(widget, name) if (!GTK_IS_TOGGLE_BUTTON(widget)) { PyErr_Format(PyExc_ValueError, "Widget '%s' is not a toggle button", name); return NULL; }
#define gtktester_abort_if_not_entry(widget, name) if (!GTK_IS_ENTRY(widget)) { PyErr_Format(PyExc_ValueError, "Widget '%s' is not an entry", name); return NULL; }
#define gtktester_abort_if_not_combo_box(widget, name) if (!GTK_IS_COMBO_BOX(widget)) { PyErr_Format(PyExc_ValueError, "Widget '%s' is not a combo box", name); return NULL; }
#define gtktester_abort_if_negative(wait) if (wait < 0) { PyErr_Format(PyExc_ValueError, "Bad negative value '%d'", wait); return NULL; }

#define gtktester_abort_if_not_string_arg(var) 	if (!PyArg_ParseTuple(args, "s", &var)) { PyErr_SetString(PyExc_KeyError, "Expected a widget descriptor"); return NULL; }
#define gtktester_abort_if_not_no_args  if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_KeyError, "No arguments expected"); return NULL; }
#define gtktester_abort_if_not_int_arg(var) if (!PyArg_ParseTuple(args, "i", &var)) { PyErr_SetString(PyExc_KeyError, "Expected an integer"); return NULL; }
#define gtktester_abort_if_not_two_int_args(a, b) if (!PyArg_ParseTuple (args, "ii", &a, &b)) { PyErr_SetString(PyExc_KeyError, "Expected two integer arguments"); return NULL; }


#endif /* GTKTESTER_VALIDATIONS_H */
